﻿using FEM.Basic;
using PGMHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PBSD_Development
{
    /// <summary>
    /// 剪力墙边缘构件
    /// </summary>
    public class WallBoundarySection
    {
        /// <summary>
        /// 边缘构件长度
        /// </summary>
        public double bLength { set; get; }

        /// <summary>
        ///  厚度放大系数
        /// </summary>
        public double tFactor { set; get; }

        /// <summary>
        /// 含钢率
        /// </summary>
        public double steelRatio { set; get; }

        /// <summary>
        /// 边缘构件体积配箍率
        /// </summary>
        public double bStirrupVRatio { set; get; }

        /// <summary>
        /// 纵筋配筋率
        /// </summary>
        public double bAsRatio { set; get; }

        /// <summary>
        /// 型钢面积
        /// </summary>
        /// <param name="thick"></param>
        /// <returns></returns>
        public double GetSteelArea(double thick)
        {
            return thick * this.bLength * this.tFactor * this.steelRatio;
        }

        /// <summary>
        /// 型钢面积
        /// </summary>
        /// <param name="thick"></param>
        /// <returns></returns>
        public double GetConcreteArea(double thick)
        {
            return thick * this.bLength * this.tFactor;
        }

        /// <summary>
        /// 信息是否正确
        /// </summary>
        /// <returns></returns>
        public bool isCorrect()
        {
            //边缘构件是否存在
            if (this.bLength == 0) return true;
            //尺寸是否正确
            if (this.bLength < 0 || this.tFactor <= 0)
                return MessageBoxExtern.Error("边缘构件尺寸错误！");
            //配筋
            if (this.bAsRatio <= 0 || this.bStirrupVRatio <= 0)
                return MessageBoxExtern.Error("边缘构件配筋错误！");
            //含钢率
            if (this.steelRatio < 0)
                return MessageBoxExtern.Error("边缘构件含钢率错误！");
            return true;
        }

        /// <summary>
        /// 获得子截面信息
        /// </summary>
        /// <returns></returns>
        public Wall_Sub_Section GetWall_Sub_Section(WALL_Section section)
        {
            //计算等效配筋率
            var AsRatio = (this.bAsRatio + this.steelRatio * section.Steel_Grade / section.Bar_Grade) * 100;
            //子墙数据
            return new Wall_Sub_Section
            {
                is_Confined = false,
                Length = (float)this.bLength,
                As_Ratio = (float)AsRatio,
                Fiber_Number = 2,
                Stirrup_V_Ratio = (float)this.bStirrupVRatio,
                Stirrup_Space = 100,
            };
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public WallBoundarySection()
        {
            this.bLength = 0;
            this.tFactor = 1;
        }
    }
}
